'use strict'

//1.导包
const express = require('express')
const path = require('path')
//服务器端开辟内存空间的技术方案
const session = require('express-session')
//解析post请求的
const bodyParser = require('body-parser')

//2.create app
const app = express()

// Use the session middleware 
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}))

//设置静态资源根路径
app.use(express.static(path.join(__dirname,'statics')))

// parse application/x-www-form-urlencoded 
app.use(bodyParser.urlencoded({ extended: false }))

//3.请求、处理、响应
const accountRouter = require(path.join(__dirname,'routers/accountRouter.js'))
app.use('/account',accountRouter)

//4.开启
app.listen(3000,'192.168.117.81',err=>{
  if (err) {
    console.log(err)
  }
  console.log("start OK")
})

